home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / pj64.arc / OX.ASM < prev    next >
Assembly Source File  |  1988-12-16  |  8KB  |  461 lines

  1.     page    60,132
  2.     title    AuxDrv - Monochrome AUX driver
  3.  
  4. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5.  
  6. ; This device directs AUX output to the Monochrome display, and AUX input to
  7. ; the BIOS.  At boot time, it saves the vectors for INT 9 and INT 16h, and
  8. ; when AUX input is requested temporarily restores them.  So, it can be used
  9. ; for AUX input and output from inside Windows.
  10.  
  11. ; You should still use the /M option with SymDeb rather than /"=AUX", because
  12. ; SymDeb has a bug where it puts out memory allocation messages to CON even
  13. ; though you said /"=AUX".
  14.  
  15. ; It's also handy in DOS; you can do, for example, TYPE FOO >AUX and it will
  16. ; go to the Monochrome screen.    You can even say CTTY AUX if you don't feel
  17. ; like saying MODE MONO...
  18.  
  19. ; In case you're wondering why the screen output code is so simple (i.e. there
  20. ; is no "current row" variable), it always outputs to the last row of the
  21. ; screen, instead of starting at the top.  Don't laugh, it works fine and made
  22. ; it easier to code this pup.
  23.  
  24. ; This driver is in the public domain.    If you find it useful, how about
  25. ; returning the favor and putting some of your own favorite utilities in
  26. ; the public domain, too?  (***with source code!!!***)
  27.  
  28. ; Michael Geary (GEnie: GEARY; BIX: GEARY; CompuServe: 76146,42)
  29.  
  30. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  31.  
  32. ; Far return so we don't have to use PROCs
  33.  
  34. retf    MACRO
  35.     db    0CBh
  36.     ENDM
  37.  
  38. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  39.  
  40. ; request header entries
  41.  
  42. cmdCode     equ    2
  43. status        equ    3
  44.  
  45. ndInputChar    equ    13
  46.  
  47. brkOff        equ    14
  48. brkSeg        equ    brkOff+2
  49.  
  50. xferOff     equ    14
  51. xferSeg     equ    xferOff+2
  52.  
  53. xferCount    equ    18
  54.  
  55. ; constants
  56.  
  57. BS        equ    08h
  58. TAB        equ    09h
  59. LF        equ    0Ah
  60. CR        equ    0Dh
  61.  
  62. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  63.  
  64. Zseg        segment at 0
  65.  
  66.         org     9*4
  67. KbdInt        label   dword
  68. KbdIntOff   dw        ?
  69. KbdIntSeg   dw        ?
  70.  
  71.         org     16h*4
  72. KbdBios     label   dword
  73. KbdBiosOff  dw        ?
  74. KbdBiosSeg  dw        ?
  75.  
  76. Zseg        endS
  77.  
  78. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  79.  
  80. Cseg    segment para public 'code'
  81.  
  82.         assume    cs:Cseg, ds:nothing, es:nothing
  83. begin:
  84.  
  85. ; device driver header
  86.  
  87. nextDev     dd    -1
  88. attribute    dw    1000100000000000b
  89. strategy    dw    devStrategy
  90. interrupt    dw    devInt
  91. devName     db    'AUX     '
  92.  
  93. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  94.  
  95. rhAddr        label    dword
  96. rhOff        dw    ?
  97. rhSeg        dw    ?
  98.  
  99. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  100.  
  101. funTab        label    word
  102.         dw    init
  103.         dw    mediaCheck
  104.         dw    buildBpb
  105.         dw    ioCtlIn
  106.         dw    input
  107.         dw    ndInput
  108.         dw    inStat
  109.         dw    inFlush
  110.         dw    output
  111.         dw    outVerify
  112.         dw    outStat
  113.         dw    outFlush
  114.         dw    ioCtlOut
  115.         dw    open
  116.         dw    close
  117.  
  118. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  119.  
  120. scrMinOff    equ    160*24
  121. scrMaxOff    equ    160*25
  122.  
  123. scrCurOff    dw    scrMinOff
  124.         dw    0B000h
  125.  
  126. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  127.  
  128. SaveKbdInt    label    dword
  129. SaveKbdIntOff    dw    0
  130. SaveKbdIntSeg    dw    0
  131.  
  132. SaveKbdBios    label    dword
  133. SaveKbdBiosOff    dw    0
  134. SaveKbdBiosSeg    dw    0
  135.  
  136. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  137.  
  138. devStrategy:
  139.     mov    cs:rhSeg, es
  140.     mov    cs:rhOff, bx
  141.     retf
  142.  
  143. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  144.  
  145. devInt:
  146.     pushf
  147.     push    ds
  148.     push    es
  149.     push    ax
  150.     push    bx
  151.     push    cx
  152.     push    dx
  153.     push    di
  154.     push    si
  155.     cld
  156.  
  157.     les    bx, cs:rhAddr
  158.     mov    al, es:[bx].cmdCode
  159.     shl    al, 1
  160.     lea    di, funTab
  161.     xor    ah, ah
  162.     add    di, ax
  163.     jmp    word ptr[di]
  164.  
  165. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  166.  
  167. outVerify:
  168. output:
  169.     mov    cx, es:[bx].xferCount    ; CX = # bytes to write
  170.     lds    si, es:[bx].xferOff    ; DS:SI --> text
  171.  
  172.     les    di, dword ptr scrCurOff
  173.  
  174. outLoop:
  175.     lodsb
  176.  
  177.     cmp    al, CR
  178.     ja    outChar
  179.     je    outCR
  180.  
  181.     cmp    al, LF
  182.     je    outLF
  183.  
  184.     cmp    al, TAB
  185.     je    outTAB
  186.  
  187.     cmp    al, BS
  188.     je    outBS
  189.  
  190. outChar:
  191.     stosb
  192.     inc    di
  193.     cmp    di, scrMaxOff
  194.     jb    outDone
  195.  
  196.     mov    di, scrMinOff
  197.  
  198. outLF:
  199.     push    ds
  200.     push    es
  201.     push    si
  202.     push    di
  203.     push    cx
  204.  
  205.     mov    ax, es
  206.     mov    ds, ax
  207.  
  208.     xor    di, di            ; Scroll screen
  209.     mov    si, 160
  210.     mov    cx, 24*80
  211.     rep movsw
  212.  
  213.     mov    ax, 0720h        ; Blank bottom line
  214.     mov    cx, 80
  215.     rep stosw
  216.  
  217.     pop    cx
  218.     pop    di
  219.     pop    si
  220.     pop    es
  221.     pop    ds
  222.  
  223.     jmp    outDone
  224.  
  225. outBS:
  226.     cmp    di, scrMinOff
  227.     je    outDone
  228.     sub    di, 2
  229.     jmp    outDone
  230.  
  231. outTAB:
  232.     or    di, 0Eh
  233.     jmp    outDone
  234.  
  235. outCR:
  236.     mov    di, scrMinOff
  237.  
  238. outDone:
  239.     loop    outLoop
  240.     mov    scrCurOff, di
  241.  
  242.     mov    dx, 3B4h
  243.     shr    di, 1            ; Set cursor position
  244.     mov    ax, di
  245.     mov    al, 0Eh
  246.     out    dx, ax
  247.     mov    ax, di
  248.     xchg    ah, al
  249.     mov    al, 0Fh
  250.     out    dx, ax
  251.  
  252.     jmp    exit
  253.  
  254. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  255.  
  256. input:
  257.     call    SetOldKbdInts
  258.  
  259.     mov    ah, 0
  260.     int    16h
  261.  
  262.     les    di, es:[bx].xferOff    ; ES:DI --> text
  263.     stosb
  264.     mov    byte ptr es:[bx].xferCount, 1
  265.  
  266.     call    SetNewKbdInts
  267.  
  268.     jmp    exit
  269.  
  270. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  271.  
  272. ndInput:
  273.     call    SetOldKbdInts
  274.  
  275.     mov    ah, 1
  276.     int    16h
  277.     jz    ndInputNone
  278.  
  279.     mov    es:[bx].ndInputChar, al
  280.  
  281.     call    SetNewKbdInts
  282.  
  283.     jmp    exit
  284.  
  285. ndInputNone:
  286.     call    SetNewKbdInts
  287.  
  288.     les    bx, rhAddr
  289.     or    word ptr es:status[bx], 0300h    ; set busy flag
  290.  
  291.     jmp    exit1
  292.  
  293. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  294.  
  295. inStat:
  296.     call    SetOldKbdInts
  297.  
  298.     mov    ah, 1
  299.     int    16h
  300.     jz    ndInputNone
  301.  
  302.     call    SetNewKbdInts
  303.  
  304.     jmp    exit
  305.  
  306. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  307.  
  308. inFlush:
  309.     call    SetOldKbdInts
  310.  
  311. inFlushLoop:
  312.     mov    ah, 1
  313.     int    16h
  314.     jz    inFlushDone
  315.  
  316.     mov    ah, 0
  317.     int    16h
  318.     jmp    inFlushLoop
  319.  
  320. inFlushDone:
  321.     call    SetNewKbdInts
  322.  
  323.     jmp    exit
  324.  
  325. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  326.  
  327. open:
  328.     mov    dx, 3B4h        ; Set standard monochrome cursor
  329.     mov    ax, 0B0Ah
  330.     out    dx, ax
  331.     mov    ax, 0C0Bh
  332.     out    dx, ax
  333.  
  334. close:
  335.     jmp    exit
  336.  
  337. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  338.  
  339. mediaCheck:
  340. buildBpb:
  341. ioCtlIn:
  342. ioCtlOut:
  343. outStat:
  344. outFlush:
  345.  
  346. exit:
  347.     les    bx, rhAddr
  348.     or    word ptr es:status[bx], 0100h
  349. exit1:
  350.     pop    si
  351.     pop    di
  352.     pop    dx
  353.     pop    cx
  354.     pop    bx
  355.     pop    ax
  356.     pop    es
  357.     pop    ds
  358.     popf
  359.     retf
  360.  
  361. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  362.  
  363. SetOldKbdInts:
  364.  
  365.     push    es
  366.     push    ax
  367.     xor    ax, ax
  368.     mov    es, ax
  369.     assume    es:Zseg
  370.  
  371.     CLI
  372.  
  373.     mov    ax, SaveKbdIntOff
  374.     xchg    ax, KbdIntOff
  375.     mov    SaveKbdIntOff, ax
  376.  
  377.     mov    ax, SaveKbdIntSeg
  378.     xchg    ax, KbdIntSeg
  379.     mov    SaveKbdIntSeg, ax
  380.  
  381.     mov    ax, SaveKbdBiosOff
  382.     xchg    ax, KbdBiosOff
  383.     mov    SaveKbdBiosOff, ax
  384.  
  385.     mov    ax, SaveKbdBiosSeg
  386.     xchg    ax, KbdBiosSeg
  387.     mov    SaveKbdBiosSeg, ax
  388.  
  389.     STI
  390.  
  391.     pop    ax
  392.     pop    es
  393.     assume    es:nothing
  394.  
  395.     ret
  396.  
  397. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  398.  
  399. SetNewKbdInts:
  400.  
  401.     push    es
  402.     push    ax
  403.     xor    ax, ax
  404.     mov    es, ax
  405.     assume    es:Zseg
  406.  
  407.     CLI
  408.  
  409.     mov    ax, SaveKbdIntOff
  410.     mov    KbdIntOff, ax
  411.  
  412.     mov    ax, SaveKbdIntSeg
  413.     mov    KbdIntSeg, ax
  414.  
  415.     mov    ax, SaveKbdBiosOff
  416.     mov    KbdBiosOff, ax
  417.  
  418.     mov    ax, SaveKbdBiosSeg
  419.     mov    KbdBiosSeg, ax
  420.  
  421.     STI
  422.  
  423.     pop    ax
  424.     pop    es
  425.     assume    es:nothing
  426.  
  427.     ret
  428.  
  429. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  430.  
  431. init:    ; everything from here on is discarded
  432.  
  433.     push    es
  434.     xor    ax, ax
  435.     mov    es, ax
  436.     assume    es:Zseg
  437.  
  438.     mov    ax, KbdIntOff
  439.     mov    SaveKbdIntOff, ax
  440.     mov    ax, KbdIntSeg
  441.     mov    SaveKbdIntSeg, ax
  442.  
  443.     mov    ax, KbdBiosOff
  444.     mov    SaveKbdBiosOff, ax
  445.     mov    ax, KbdBiosSeg
  446.     mov    SaveKbdBiosSeg, ax
  447.  
  448.     pop    es
  449.     assume    es:nothing
  450.  
  451.     mov    es:brkSeg[bx], cs
  452.     mov    es:word ptr brkOff[bx], offset init
  453.  
  454.     jmp    exit
  455.  
  456. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  457.  
  458. Cseg    endS
  459.  
  460.     end    begin
  461.